package com.hbgc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hbgc.mapper.TbUserMapper;
import com.hbgc.pojo.TbType;
import com.hbgc.pojo.TbUser;
import com.hbgc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private TbUserMapper tbUserMapper;

    @Override
    public PageInfo queryTbbUserByPage(int pageNow, int pageSize, String username) {
        PageHelper.startPage(pageNow,pageSize);
        List list = tbUserMapper.selectAllByUsername(username);
        PageInfo pageInfo=new PageInfo(list);
        return pageInfo;
    }

    @Override
    public boolean saveTbbUser(TbUser tbUser) {
        return tbUserMapper.insert(tbUser)>0?true:false;
    }

    @Override
    public boolean updateTbbUserById(TbUser tbUser) {
        return tbUserMapper.updateByPrimaryKey(tbUser)>0?true:false;
    }

    @Override
    public boolean deleteTbUserById(Long uid) {
        return tbUserMapper.deleteByPrimaryKey(uid)>0?true:false;
    }

    @Override
    public TbUser getTbbUserById(Long uid) {
        return tbUserMapper.selectByPrimaryKey(uid);
    }
}
